package obj.day6;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Duration;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.Period;
import java.time.format.DateTimeFormatter;
import java.util.Date;
import java.util.Scanner;

/**
 * @author げっしょく
 * @date 2021/7/22
 */
public class exam {
    public static void main(String[] args) throws ParseException {
        LocalDateTime of = LocalDateTime.of(2001, 2, 20,0,0,0);
        LocalDateTime now = LocalDateTime.now();
        Duration between = Duration.between(of, now);
        System.out.println(between.toDays());
        //tet4_1();
        //test3();
        //test2();
        //test();
    }

    private static void tet4_1() throws ParseException {
        Scanner sc = new Scanner(System.in);
        System.out.println("按照以下格式输入你的出生日期");
        System.out.println("xxx-xx-xx");
        String s = sc.nextLine();
        Date date = new Date();
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(s);
        long time1 = parse.getTime();
        Date date1 = new Date();
        long time = date1.getTime();
        long l = time - time1;
        long i = l / (24 * 3600 * 1000);
        System.out.println(i);
    }

    private static void test3() {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = sc.nextInt();
        LocalDate of = LocalDate.of(year, 1, 1);
        boolean leapYear = of.isLeapYear();
        if(leapYear == true){
            System.out.println("是闰年");
        }else{
            System.out.println("是平年");
        }
    }

    private static void test2() {
        LocalDate of = LocalDate.of(2019, 2, 29);
        System.out.println("这天是星期"+of.getDayOfWeek().getValue());
    }

    private static void test() throws ParseException {
        String s = "2018-09-10";
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = dateFormat.parse(s);
        System.out.println(parse);
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日");
        System.out.println("转换后" + format.format(parse));
    }
}
